/*---------------------------------------------------------------------
 * File name: dma_buffer.hpp
 *
 * Copyright (c) <2020-2022>, <ChenLong>
 *
 * All rights reserved.
 *
 * Author: ChenLong
 * Email: worldlong@foxmail.com
 *--------------------------------------------------------------------*/
#include <stdint.h>
/*
*/
#define DMA_BUFFER_DEFINE(name, len) \
    uint8_t name##_data_buffer[len];\
    DMA_Buffer name##_dma_buffer(name##_data_buffer, len);
/*
*/
class DMA_Buffer
{
public:
  DMA_Buffer(uint8_t *buffer, int len);
  
  int transfer_number;
  
  int push(uint8_t *data, int num);
  int pop(uint8_t *data, int num);
  uint8_t *dma_push_start(int num);
  int dma_push_end(int num);
  uint8_t *dma_pop_start();
  int dma_pop_end();
  
private:
  uint8_t *_buffer;
  int _length;
  int _number;
  int _push_index;
  int _pop_index;
};




